<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:100:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\public/../application/core\view\enterprise\index\index.html";i:1544678555;s:84:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\application\core\view\common\pc\header.html";i:1544678555;s:84:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\application\core\view\common\pc\layout.html";i:1544678555;s:84:"D:\PHPStudy\PHPTutorial\WWW\HM\pdingzone\application\core\view\common\pc\footer.html";i:1544678555;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>后台管理首页 - <?php echo $siteConfig['siteName']; ?></title>
    <meta name="keywords" content="<?php echo $siteConfig['siteKeyword']; ?>"/>
    <meta name="description" content="<?php echo $siteConfig['siteDesc']; ?>"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="<?php echo $siteConfig['favicon']; ?>" type="image/x-icon" rel="shortcut icon"/>
    <link rel="stylesheet" href="/static/layui/2.4.3/src/css/layui.css?v=20181010_1" media="all">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_731151_u29ky3lpahq.css?v=20181010_1" media="all">
    <link rel="stylesheet" href="/static/css/pc.css?v=20181010_1" media="all">
    <script src="/static/js/jquery.min.js?v=20181010_1" charset="utf-8"></script>
    <script src="/static/layui/2.4.3/src/layui.js?v=20181010_1" charset="utf-8"></script>
    <script src="/static/js/common.js?v=20181010_1" charset="utf-8"></script>
    <script src="/static/js/pc.js?v=20181010_1" charset="utf-8"></script>

    <?php if($siteConfig['theme']): ?>
    <link rel="stylesheet" href="/static/css/theme/<?php echo $siteConfig['theme']; ?>/pc.css?v=20181010_1" media="all">
    <?php endif;  if(\think\App::$debug){  ?>
    <!-- 调试窗口 -->
    <script src="/static/js/vconsole/vconsole.min.js?v=20181010_1" charset="utf-8"></script>
    <script>
        // 调试窗口初始化
        new VConsole();
    </script>
    <?php  }  ?>
</head>

<body class="layui-layout-body pc-body">


<style>
    .layui-nav[lay-filter="topMenu"] {
        width: calc(100vw - 360px);
    }

    .left_menu dl.layui-nav-child dd {
        padding-left: 15px !important;
    }

    .left-menu-item.left-menu-item-title {
        border-bottom: solid 1px #40434a;
    }

    .left-menu-item.left-menu-item-title a {
        font-weight: 600 !important;
        color: #fff !important;
        text-align: center !important;
    }

    .layui-layout-admin-index .layui-nav-item-selected,
    .layui-layout-admin-index .layui-nav-item-selected > a {
        color: #fff !important;
    }

    .layui-layout-admin-index.layui-layout-admin-full .layui-side {
        display: none !important;
    }

    .layui-layout-admin-index.layui-layout-admin-full .layui-body,
    .layui-layout-admin-index.layui-layout-admin-full .layui-footer {
        left: 0px !important;
    }

    .layui-layout-admin-index .layui-tab-title {
        display: none;
    }

    .layui-layout-admin-index .layui-tab-content {
        padding: 10px 5px 0px 5px;
    }

    .layui-layout-admin-index .layui-card-body {
        padding: 0px;
        background: #f8f8f8;
    }

    .layui-layout-admin-index .layui-logo img {
        width: 150px;
        height: 45px;
    }

    .layui-layout-admin-index .layui-nav-img {
        margin-right: 0px;
    }

    .admin-iframe {
        width: 100%;
        height: 100%;
        min-height: 500px;
        min-height: calc(100vh - 170px);
    }

    .admin-iframe-loading {
        text-align: center;
        width: 100%;
        height: calc(100vh - 80px);
        background: none;
    }

    .admin-iframe-loading img {
        height: 60px;
        margin-top: calc(50vh - 60px);
    }

    .layui-layout-admin .layui-side,
    .layui-side-scroll,
    .layui-nav-tree {
        width: 160px !important;
    }

    .layui-body {
        left: 160px !important;
        bottom: 0 !important;
    }
</style>

<div class="layui-layout layui-layout-admin layui-layout-admin-index">
    <div class="layui-header">
        <div class="layui-logo">
            <a href="<?php echo $indexUrl; ?>">
                <img src="<?php echo $siteConfig['logo']; ?>" title="<?php echo $siteConfig['siteName']; ?>" onerror="this.src='/static/images/logo.png';"/>
            </a>
        </div>
        <ul class="layui-nav layui-layout-left" lay-filter="topMenu">
            <?php if(is_array($menus) || $menus instanceof \think\Collection || $menus instanceof \think\Paginator): $topIdx = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($topIdx % 2 );++$topIdx;
            $menuAttrs = [];
            if(isset($menu['attr'])) {
            foreach($menu['attr'] as $k => $v) {
            $menuAttrs[] = $k.'="'.$v.'"';
            }
            }
            $menuAttrs = join(" ", $menuAttrs);
             ?>
            <li class='layui-nav-item top-menu-item' id="top-menu-item-<?php echo $topIdx; ?>" <?php echo $menuAttrs; ?> data-idx="<?php echo $topIdx; ?>">
                <a href="javascript:;" onclick="switchTopMenu(<?php echo $topIdx; ?>)"
                   data-link='<?php if(isset($menu['link'])): ?><?php echo $menu['link']; endif; ?>'
                ><?php echo $menu['title']; ?></a>
            </li>
            <?php endforeach; endif; else: echo "" ;endif; ?>
            <li class="layui-nav-item top-menu-item-more" style="display: none;">
                <a href="javascript:;">查看更多</a>
                <dl class="layui-nav-child layui-text-center">
                    <?php if(is_array($menus) || $menus instanceof \think\Collection || $menus instanceof \think\Paginator): $topIdx = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($topIdx % 2 );++$topIdx;?>
                    <dd id="top-menu-item-more-<?php echo $topIdx; ?>" style="display: none;">
                        <a href="javascript:;" onclick="switchTopMenu(<?php echo $topIdx; ?>)"
                           data-link='<?php if(isset($menu['link'])): ?><?php echo $menu['link']; endif; ?>'
                        ><?php echo $menu['title']; ?></a>
                    </dd>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img src="<?php echo $userAvatar; ?>" onerror="this.src='/static/images/avatar.png';" class="layui-nav-img">
                    <?php echo $userName; ?>
                </a>
                <dl class="layui-nav-child layui-text-center">
                    <?php if(is_array($userMenus) || $userMenus instanceof \think\Collection || $userMenus instanceof \think\Paginator): if( count($userMenus)==0 ) : echo "" ;else: foreach($userMenus as $key=>$userMenu): ?>
                    <dd>
                        <a href="javascript:;"
                           onclick="openDialog('<?php echo $userMenu['title']; ?>','<?php echo $userMenu['link']; ?>');"><?php echo $userMenu['title']; ?></a>
                    </dd>
                    <?php endforeach; endif; else: echo "" ;endif; ?>
                    <dd>
                        <hr/>
                    </dd>
                    <dd>
                        <a href="<?php echo $logoutUrl; ?>">退出登录</a>
                    </dd>
                </dl>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <?php if(is_array($menus) || $menus instanceof \think\Collection || $menus instanceof \think\Paginator): $topIdx = 0; $__LIST__ = $menus;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$menu): $mod = ($topIdx % 2 );++$topIdx;?>
            <ul class="layui-nav layui-nav-tree left_menu" lay-filter="leftMenu_<?php echo $topIdx; ?>" id="left_menu_<?php echo $topIdx; ?>"
                style="display:none;">
                <?php if(isset($menu['left'])): ?>
                <li class='layui-nav-item left-menu-item left-menu-item-title' id="left_menu_<?php echo $topIdx; ?>_0_0">
                    <?php $link = isset($menu['link']) ? $menu['link']:""; ?>
                    <a href="javascript:;" onclick="switchLeftMenu(<?php echo $topIdx; ?>,0,0)" data-link="<?php echo $link; ?>">
                        <?php echo $menu['title']; ?>
                    </a>
                </li>
                <?php if(is_array($menu['left']) || $menu['left'] instanceof \think\Collection || $menu['left'] instanceof \think\Paginator): $leftIdx = 0; $__LIST__ = $menu['left'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$leftMenu): $mod = ($leftIdx % 2 );++$leftIdx;?>
                <li class='layui-nav-item left-menu-item' id="left_menu_<?php echo $topIdx; ?>_<?php echo $leftIdx; ?>_0">
                    <?php if(isset($leftMenu['sub']) && count($leftMenu['sub']) > 0): ?>
                    <a href="javascript:;">
                        <?php echo $leftMenu['title']; ?>
                    </a>
                    <dl class="layui-nav-child">
                        <?php if(is_array($leftMenu['sub']) || $leftMenu['sub'] instanceof \think\Collection || $leftMenu['sub'] instanceof \think\Paginator): $subLeftIdx = 0; $__LIST__ = $leftMenu['sub'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$subLeftMenu): $mod = ($subLeftIdx % 2 );++$subLeftIdx;?>
                        <dd id="left_menu_<?php echo $topIdx; ?>_<?php echo $leftIdx; ?>_<?php echo $subLeftIdx; ?>">
                            <a href="javascript:;" onclick="switchLeftMenu(<?php echo $topIdx; ?>,<?php echo $leftIdx; ?>,<?php echo $subLeftIdx; ?>)"
                               data-link='<?php echo $subLeftMenu['link']; ?>'><?php echo $subLeftMenu['title']; ?></a>
                        </dd>
                        <?php endforeach; endif; else: echo "" ;endif; ?>
                    </dl>
                    <?php else: $link = isset($leftMenu['link']) ? $leftMenu['link']:""; ?>
                    <a href="javascript:;" onclick="switchLeftMenu(<?php echo $topIdx; ?>,<?php echo $leftIdx; ?>,0)"
                       data-link='<?php echo $link; ?>'>
                        <?php echo $leftMenu['title']; ?>
                    </a>
                    <?php endif; ?>
                </li>
                <?php endforeach; endif; else: echo "" ;endif; endif; ?>
            </ul>
            <?php endforeach; endif; else: echo "" ;endif; ?>
        </div>
    </div>

    <div class="layui-body">
        <div class="layui-card">
            <!-- <div class="layui-card-header"></div> -->
            <div class="layui-card-body">
                <div class="layui-tab" lay-allowClose="true" lay-filter="tabs" id="tabs">
                    <ul class="layui-tab-title">
                    </ul>
                    <div class="layui-tab-content">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    if (!String.prototype.startsWith) {
        String.prototype.startsWith = function (search, pos) {
            return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
        };
    }

    var defaultHash = window.location.hash;
    layui.use(['element', 'layer', 'jquery'], function () {
        var $ = layui.$,
            element = layui.element,
            layer = layui.layer;
        window.$ = $;
        window.element = element;
        window.layer = layer;

        //默认显示头部第一个菜单
        var defaultTopMenuIdx = 1;
        if (document.location.hash) {
            defaultTopMenuIdx = document.location.hash.substr(1);
            if ($("#top-menu-item-" + defaultTopMenuIdx).length == 0) {
                defaultTopMenuIdx = 1;
            }
        }
        switchTopMenu(defaultTopMenuIdx);

        openTabByHash(defaultHash);

        //监听tab切换
        element.on('tab(tabs)', function (data) {
            var tabId = $(this).attr("lay-id");
            var tabIdItems = tabId.split("_");
            var topIdx = tabIdItems[1];
            var leftIdx = tabIdItems[2];
            var subLeftIdx = tabIdItems[3];
            resetLeftMenuStyle(topIdx, leftIdx, subLeftIdx);
            if (!$(this).attr('data-tab-created')) {
                // 说明是新开的tab
                $(this).attr('data-tab-created', new Date().getTime());
            } else {
                // 说明这个tab是之前就有的，用户重新点回了这个tab
                var iframe = document.getElementById('admin-iframe-' + tabId);
                // 检查如果iframe内部设置了reload_when_tab_focus，则对iframe中的内容进行刷新
                if (iframe && iframe.contentWindow && iframe.contentWindow.reload_when_tab_focus) {
                    iframe.contentWindow.document.location.reload();
                }
            }
        });
    });

    /**
     * 根据url的hash打开指定tab
     */
    function openTabByHash(hash) {
        if (hash.startsWith("#module_")) {
            var mid = hash.replace("#module_", "");
            $(".top-menu-item[mid='" + mid + "'] a").click();
        } else if (hash.startsWith("#leftMenu_")) {
            var menus = hash.replace("#leftMenu_", "").split("_");
            switchTopMenu(menus[0], menus[1], menus[2]);
        } else if (hash.startsWith("#topMenu_")) {
            var menu = hash.replace("#topMenu_", "");
            switchTopMenu(menu);
        }
    }

    //顶部菜单切换
    var currentTopIdx;

    function switchTopMenu(topIdx, leftIdx, subLeftIdx) {
        //切换顶部菜单样式
        $(".top-menu-item").removeClass("layui-this");
        $("#top-menu-item-" + topIdx).addClass("layui-this");
        //切换左侧菜单
        $(".left_menu").hide();
        $("#left_menu_" + topIdx).show();

        //清除现有tab
        if (currentTopIdx != topIdx) {
            clearTabs();
        }
        currentTopIdx = topIdx;

        $(".layui-layout-admin").removeClass("layui-layout-admin-full");
        var leftCount = $("#left_menu_" + topIdx + " li").length;
        if (leftCount == 0) {
            //无左侧菜单，隐藏左侧
            $(".layui-layout-admin").addClass("layui-layout-admin-full");
            var aid = "#top-menu-item-" + topIdx + ">a";
            var title = $(aid).text();
            var link = $(aid).attr("data-link");

            var tabId = "topMenu_" + topIdx;
            openTab(title, link, tabId);
        } else {
            //打开左侧菜单的第一个菜单
            if (!leftIdx) {
                if ($("#left_menu_" + topIdx + "_0_0>a").attr("data-link")) {
                    leftIdx = 0;
                } else {
                    leftIdx = 1;
                }
            }
            if (!subLeftIdx) {
                subLeftIdx = 0;
                if ($("#left_menu_" + topIdx + "_" + leftIdx + "_0>dl").length > 0) {
                    //有二级菜单
                    subLeftIdx = 1;
                }
            }
            switchLeftMenu(topIdx, leftIdx, subLeftIdx);
        }
    }

    /**
     * 切换左侧菜单
     **/
    function switchLeftMenu(topIdx, leftIdx, subLeftIdx) {
        var aid = "#left_menu_" + topIdx + "_" + leftIdx + "_" + subLeftIdx + ">a";
        var title = $(aid).text();
        var link = $(aid).attr("data-link");

        if (subLeftIdx != 0) {
            title = $("#left_menu_" + topIdx + "_" + leftIdx + "_0>a").text() + " - " + title;
        }

        resetLeftMenuStyle(topIdx, leftIdx, subLeftIdx);

        var tabId = "leftMenu_" + topIdx + "_" + leftIdx + "_" + subLeftIdx;
        openTab(title, link, tabId);
    }

    /**
     * 重设左侧菜单样式
     **/
    function resetLeftMenuStyle(topIdx, leftIdx, subLeftIdx) {
        var aid = "#left_menu_" + topIdx + "_" + leftIdx + "_" + subLeftIdx;
        if (!$(aid).length) {
            return;
        }
        $("ul.left_menu .layui-this").removeClass("layui-this");
        $(aid).addClass("layui-this");

        if (subLeftIdx > 0) {
            $(aid).parents(".left-menu-item").addClass("layui-nav-itemed");
        }
    }

    /**
     * 尝试根据链接重设左侧菜单样式
     */
    function tryToResetLeftMenuStyleByLink(link) {
        try {
            var linkWithoutParam = link.indexOf("?") == -1 ? link : link.substr(0, link.indexOf("?"));
            var $leftMenu = $("ul.left_menu:visible").first();
            var $fullMatchA = false;
            var $pathMatchA = false;
            $leftMenu.find("a").each(function () {
                var dataLink = $(this).attr("data-link");
                if (!dataLink) {
                    return;
                }
                if (dataLink == link) {
                    $fullMatchA = $(this);
                    $pathMatchA = $(this);
                    return;
                }
                var dataLinkWithoutParam = dataLink.indexOf("?") == -1 ? dataLink : dataLink.substr(0, dataLink.indexOf("?"));
                if (dataLinkWithoutParam == linkWithoutParam) {
                    $pathMatchA = $(this);
                }
            });

            if ($fullMatchA) {
                $("ul.left_menu .layui-this").removeClass("layui-this");
                $($fullMatchA).parent().addClass("layui-this");
            } else if ($pathMatchA) {
                $("ul.left_menu .layui-this").removeClass("layui-this");
                $($pathMatchA).parent().addClass("layui-this");
            }
        } catch (e) {
            console.error(e);
        }
    }

    /**
     * 清空所有tab
     **/
    function clearTabs() {
        $("#tabs ul li").each(function () {
            element.tabDelete('tabs', $(this).attr('lay-id'));
        });
    }

    /**
     * 调转到某个tab
     * */
    function jumpToThisTab(link) {
        $("#tabs ul li").each(function () {
            if ($(this).attr("data-link") == link) {
                element.tabChange('tabs', $(this).attr('lay-id'));
            }
        });
    }

    /**
     * 关闭tab
     * */
    function closeThisTab(link) {
        $("#tabs ul li").each(function () {
            if ($(this).attr("data-link") == link) {
                element.tabDelete('tabs', $(this).attr('lay-id'));
            }
        });
    }

    /**
     * 打开tab
     **/
    function openTab(title, link, tabId) {
        if (!link || link == "null" || link == "#" || link == "javascript:;") {
            return;
        }
        if (!title) {
            title = "加载中...";
        }
        if (!tabId) {
            tabId = "link_" + link.replace(/\//g, '_').replace(/\\/g, "_").replace(/\./g, "_").replace(/\?/g, "_").replace(/=/g, "_");
            tryToResetLeftMenuStyleByLink(link);
        }
        if ($(".layui-layout-admin-index .layui-tab-title").is(":hidden")) {
            // 如果tab标题是隐藏的，那么关闭其他标签
            clearTabs();
        }

        if ($("#tabs ul li[lay-id='" + tabId + "']").length <= 0) {
            var html = '';
            html += '<div class="admin-iframe-loading" id="admin-iframe-loading-' + tabId + '">';
            html += '<img src="/static/images/loading.svg"/>';
            html += '</div>';
            html += '<iframe id="admin-iframe-' + tabId + '" src="' + link + '" frameborder="0" class="admin-iframe"></iframe>';
            element.tabAdd('tabs', {
                title: title,
                content: html,
                id: tabId
            });
            initTabContentLoading(tabId);
        }
        element.tabChange("tabs", tabId);
        $("#tabs ul li[lay-id='" + tabId + "']").attr("data-link", link);

        var mainHeight = $(".layui-layout-admin-index .layui-body").height();
        $("#admin-iframe-" + tabId).css("min-height", (mainHeight - 20) + "px");

        window.location.hash = tabId;
    }

    /**
     * tab内容加载中
     *
     * @param tabId
     */
    function initTabContentLoading(tabId) {
        var iframe = document.getElementById("admin-iframe-" + tabId);
        $("#admin-iframe-" + tabId).hide();
        if (iframe.attachEvent) {
            iframe.attachEvent("onload", function () {
                onFrameLoadCompleted(tabId);
            });
        } else {
            iframe.onload = function () {
                onFrameLoadCompleted(tabId);
            };
        }
        //兜底,5s还没load完成，就强制显示出来
        setTimeout("onFrameLoadCompleted('" + tabId + "')", 5000);
    }

    function onFrameLoadCompleted(tabId) {
        $("#admin-iframe-" + tabId).show();
        $("#admin-iframe-loading-" + tabId).remove();

        // 修改tab上面的标题
        var iframe = document.getElementById("admin-iframe-" + tabId);
        if (!iframe || !iframe.contentWindow) {
            return;
        }
        var title = iframe.contentWindow.document.title;
        title = title.replace(" - <?php echo $siteConfig['siteName']; ?>", "");
        var titleNode = $("#tabs ul li[lay-id='" + tabId + "']")[0].childNodes[0];
        if (titleNode.data && titleNode.data == '加载中...') {
            titleNode.data = title;
        }
    }

    /**
     * 顶部菜单重新排列
     */
    function resetTopMenu() {
        var topMenuWidth = $('.layui-nav[lay-filter="topMenu"]').width();
        var totalWidth = 0;
        $('.layui-nav[lay-filter="topMenu"] .top-menu-item').each(function () {
            var idx = $(this).attr("data-idx");
            totalWidth += $(this).width();
            if (totalWidth + 100 > topMenuWidth) {
                $(this).hide();
                $("#top-menu-item-more-" + idx).show();
            } else {
                $(this).show();
                $("#top-menu-item-more-" + idx).hide();
            }
        });
        if (totalWidth + 100 > topMenuWidth) {
            $(".top-menu-item-more").show();
        } else {
            $(".top-menu-item-more").hide();
        }
    }


    /**
     * 打开弹窗
     */
    function openDialog(title, url) {
        layer.open({
            type: 2,
            title: title,
            shadeClose: true,
            shade: 0.8,
            maxmin: false,
            resize: true,
            area: ['80vw', '80vh'],
            content: url,
            cancel: function () {
            }
        });
    }
    
    $(document).ready(function () {
        resetTopMenu();
    });
    $(window).resize(function () {
        resetTopMenu();
    });
</script>


<?php 
if(isset($_enterprise_js_css_customize)) {
echo $_enterprise_js_css_customize;
}
 ?>
</body>
</html>